import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class TextFieldDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TextFieldDemoState();
  }
}

class TextFieldDemoState extends State<TextFieldDemo> {
  late TextEditingController mController;

  @override
  void initState() {
    super.initState();
    mController= TextEditingController();
    mController.addListener((){
      debugPrint("listener");
    });
  }
  @override
  Widget build(BuildContext context) {
    return TextField(
      controller: mController,
      cursorColor: Colors.white,
      onChanged: (txt) => debugPrint('input text ${txt}'),
      onSubmitted: (txt)=> debugPrint('点击了确定 input text ${txt}'),
      /* minLines: 10,
      maxLines: 10,*/
        expands:true,
      maxLines: null,
      minLines: null,
      keyboardType: TextInputType.number,
      keyboardAppearance: Brightness.dark,
      textInputAction: TextInputAction.go,
      decoration: InputDecoration(
        icon: Icon(Icons.input),

        // errorText: "error",
        labelText: "placeHolder",
        floatingLabelBehavior: FloatingLabelBehavior.auto,
        hintText: "hintText",
        errorStyle: TextStyle(color: Colors.redAccent, fontSize: 23),

        fillColor: Colors.white,

        filled: true,
        constraints: BoxConstraints(maxHeight: 600, minHeight: 130),
        /*
      * border: OutlineInputBorder(
          borderRadius: BorderRadius.all(Radius.circular(1)),
            gapPadding: 8
        ),
      *
      * */
        /*以下不生效的前提 有errorText*/
        /*
        enabledBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Colors.blue, width: 2.0), // 明确设置边框颜色和宽
          borderRadius: BorderRadius.all(Radius.circular(30)),
          gapPadding: 100
        ),
        enabled: true,
        disabledBorder: OutlineInputBorder(
          borderSide: BorderSide(color: Colors.blue, width: 12.0), // 明确设置边框颜色和宽
          borderRadius: BorderRadius.all(Radius.circular(30)),
        )*/
      ),
    );
  }
}
